package com.zy.gmall.realtime.app.func;

//自定义函数1 -》 n

import com.zy.gmall.realtime.util.KeyWordUtil;
import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.FunctionHint;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.types.Row;

@FunctionHint(output = @DataTypeHint("ROW<word STRING>"))
public class KeywordUDTF extends TableFunction<Row> {
    //拿到一行数据,分词
    public void eval(String str) {
        for (String s : KeyWordUtil.analyze(str)) {
            // use collect(...) to emit a row
            collect(Row.of(s));
        }
    }

}
